/*
 * count.h
 *
 *  Created on: 2011-10-9
 *      Author: shenjiong
 */

#ifndef COUNT_H_
#define COUNT_H_

#include "ProtoFile.h"
#include "Disktools.h"

template<class T>
void getcount(std::string file, long long &x)
{
    
    ReadProtoFile a(file);
    T t1;
    x = 0;
    while(1)
    {
        if(a.GetProject(t1))
        {
            ++x;
            
        }
        else
        {
            break;
            
        }
    }
    return;
}

template<class T>
void getcountdisk(std::string disk, long long &x)
{
    x = 0;
    long long x1 = 0;
    std::list<std::string> srcfilelist;
    GetAllFile(disk.c_str(), srcfilelist);
    
    for(std::list<std::string>::iterator pos = srcfilelist.begin();
            pos != srcfilelist.end(); ++pos)
            {
        std::string filekey = disk + "/" + *pos;
        
        x1 = 0;
        getcount<T>(filekey, x1);
        std::cout << x1 << "\t" << *pos << std::endl;
        x += x1;
        
    }
    return;
}

#endif /* COUNT_H_ */
